package com.qfedu.zf.app.controller;

import com.qfedu.zf.app.service.MyFeign;
import com.qfedu.zf.common.entity.Rent;
import com.qfedu.zf.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/my")
public class MyController {
    @Autowired
    MyFeign myFeign;


//    //    my/select
//    @GetMapping("/select")
//    public R a(){
//        return myFeign.a();
//    }

    @GetMapping("/selectById")
    public R select(){
        return myFeign.select();
    }

    @PostMapping("/loadPicture")
    public R load(MultipartFile file){
        System.out.println(file);
        return myFeign.loadPicture(file);
    }

    @PostMapping("/updateName")
    public R updateName(@RequestBody com.qfedu.lc.common.entity.User user){
        System.out.println(user);
        return myFeign.updateName(user);
    }

    @PostMapping("/publish")
    public R publish(@RequestBody Rent rent){
        System.out.println("***"+rent);
        return myFeign.publish(rent);
    }
    @GetMapping("/selectPublish")
    public R selectPublish(Integer id){
        System.out.println(id+"OOOOOOOO");
        return myFeign.selectPublish(id);
    }

    @GetMapping("/deleteOn")
    public R deleteOn(){
        System.out.println("jiji");
        return myFeign.deleteOn();

    }

    @RequestMapping("collect/find")
    public R findCollect(@RequestParam("listingId") Integer listingId, HttpServletRequest request) {
        return myFeign.findCollect(listingId);
    }

    @GetMapping("collect/add")
    public R add(@RequestParam("listingId") Integer listingId, HttpServletRequest request){
        return myFeign.add(listingId);
    }
}
